package easy

import "strings"

func CountCharacters(words []string, chars string) int {
	var result int
OutLoop:
	for _, str := range words {
		for _, c := range str {
			if strings.Count(str, string(c)) > strings.Count(chars, string(c)) {
				continue OutLoop
			}
		}
		result += len(str)
	}
	return result
}
